<template>
  <div class="record">
    <c-title text="申请记录"></c-title>
    <van-tabs v-model="active"  @click="onClick">
      <van-tab title="审核通过" name="1"></van-tab>
      <van-tab title="待审核" name="0"></van-tab>
      <van-tab title="审核驳回" name="-1"></van-tab>
    </van-tabs>
    <div style="padding: 1rem;">
      <div class="box" @click="goto(item)" v-for="item in list" :key="item.id">
        <p class="time">{{item.created_at}}</p>
        <p>姓名：{{item.realname}}</p>
        <p class="mobile">手机号：{{ item.mobile }}</p>
        <p v-if="name == 'promulgator'">位置：{{item.province_name}}-{{item.city_name}}-{{item.district_name}}</p>
        <p v-else>师傅所在地：{{item.province_name}}-{{item.city_name}}-{{item.district_name}}-{{ item.street_name }}</p>
        <p class="reason" v-if="name == 'promulgator' && active=='-1'">
          <span style="flex-shrink: 0;">驳回原因:</span>
          <span style="text-overflow: ellipsis; overflow: hidden;">{{item.reason}}</span>
        </p>
      </div>
    </div>
  </div>
</template>

<script>
import { scrollMixin } from '../../../../utils/mixin';
export default {
  mixins: [scrollMixin],
  data() {
    return {
      active: "1",
      list: [],
      isLoadMore: true,
      page: 1,
      total_page: 0,

      name:"",
    };
  },
  activated() {
  //   name = 'skill_master';
  //  name = 'promulgator';
    this.name = this.$route.params.name;
    this.get_data();
  },
  methods: {
    onClick(){
      this.get_data();
    },
    goto(item){
      if(this.name == 'skill_master'){
        this.$router.push(this.fun.getUrl('anytimeRoleApply',{apply_for_type:2}))
      }else{ //发布者信息
        if(item.apply_status==0||item.apply_status==1){
            this.$router.push(this.fun.getUrl('anytimeRoleApply',{apply_for_type:1}))
          }else{
            this.$router.push(this.fun.getUrl('anytimeRoleApply',{apply_for_type:7}))
          }
      }
    },
    get_data(page=1) {
      let json={
        identity:this.name == 'skill_master' ?2:1,
        status:this.active,
        page
      }
      $http.get("plugin.be-within-call.frontend.role-apply.log",json,"").then(res=>{
        this.isLoadMore = true;
        if(res.result){
          let data = res.data;
          // this.page = data.current_page;
          // this.total_page = data.last_page;
          (page==1)?(this.list = data):(this.list=this.list.concat(data));
        }else{
          this.$toast(res.msg);
        }
      })
    },
    getMoreData(){
      this.isLoadMore = false;
      if(this.page>=this.total_page){
        return;
      }
      let page = this.page + 1;
      this.get_data(page);
    },
  }
};
</script>

<style scoped lang="scss">
.record {
  .reason {
    color: #797979;
    margin-top: 0.625rem;
    display: flex;
    overflow: hidden;
  }

  .mobile {
    margin: 0.6875rem 0;
  }

  .box {
    border-radius: 0.625rem;
    background: #fff;
    padding: 0.6875rem 1.125rem 1.375rem;
    margin-bottom: 0.875rem;
    font-size: 0.875rem;
    text-align: left;
  }

  .time {
    color: #777;
    margin-bottom: 0.875rem;
  }
}
</style>
